<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <my-component></my-component>
    <my-component></my-component>
    <my-component></my-component>
    <my-component></my-component>
  </div>
</body>
<!-- template可以提取页面的模版 -->
<template id="test">
  <h1>
    一个组件-{{ msg }}
    <button @click="add">加</button>
    {{ count }}
  </h1>
</template>
<script src="lib/vue.js"></script>
<script>
  const MyComponent = { // 大部分都类似于new vue的实例中的选项
    template: `#test`,
    data () {
      return {
        msg: 'hello component',
        count: 100
      }
    },
    methods: {
      add () {
        this.count++
      }
    }
  }
  Vue.component('my-component', MyComponent)
  new Vue({
    el: '#app'
  })
</script>
</html>